Delivery-date: Wed, 11 Dec 2024 22:15:56 -0800 Received: from mail-qv1-f55.google.com ([209.85.219.55]) by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tLcUN-0002oK-Vm for bitcoindev@gnusha.org; Wed, 11 Dec 2024 22:15:56 -0800 Received: by mail-qv1-f55.google.com with SMTP id 6a1803df08f44-6d8e815eb39sf4780986d6.2 for ; Wed, 11 Dec 2024 22:15:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1733984150; cv=pass; d=google.com; s=arc-20240605; b=C6Sj3WlJhpjWxdurquwnRXbou5nEjZGJ+3c6OACpKtyRNaZtZk762350zGcYDXJch2 iF/fz1eh9bHzUJ3M1Tlq2olHGvibz+zs1ZGMwjf2g8/uzRCjo5MDQuyJ0apvb86NtsUm 4rBaj0+bbVKNzCTdo0OHkHlilhwM0LJT7DXLysNzgTmPIT7wkUwVy+CJ9DOOhFlQNgie aLfroXF9MR5qYu6lqRKhEi5mdAc/2tbOIxN99LLcRJvyqNV6+uK8lHJGW7htyPr+UFFj dwbmisf9PgjxdxvGnRq26ikxm/pk3MAi0FXmhGAsRCJG/zqp2tmfbEhp6FhP/00AHv8c 8EXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :dkim-signature; bh=iM1TEhHXhHDjnM0SZ1wavSGFzwErB5lnlZV+YnJBxgI=; fh=AzCHzIHQbiTDdEfqwDUIN5dWhUkUq7176fZgmqFhyi0=; b=AX0XDy69QltLusVBiAvmWczVrHxAOYsf2Jx/UqWKhVzfiiRWsAPprXDDno6ZcmSv4+ OFQNAuNE2ARKOcfjZvgdhmf/6q9eYEHk4JG3KrEMqD0MbEMc0wjSvBcaiLTa39QHi/U4 bvd2z2l9S/61Ggg5UoOWG6HlkZ+gKWfGx9i2PdWdMGhj3h/JplfTarLb2/0w0QtqDFKV BCr5E4mTW0LivHMwMKexTdav3L4V1Wkm2mw+pDWaLXDWc+qzS13CPU2OC0lfWhtH1PoX V73+J4rMGtTmVQ25Y/hE87qlSWogp37y97qvgk16ISPp96+zVz5ioNaxpam+L0vlrt3s 0yzA==; darn=gnusha.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@reardencode.com header.s=mail header.b=JIi738KX; spf=pass (google.com: domain of freedom@reardencode.com designates 2607:f2f8:ad40:ea11::1 as permitted sender) smtp.mailfrom=freedom@reardencode.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=reardencode.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1733984150; x=1734588950; darn=gnusha.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:from:to:cc :subject:date:message-id:reply-to; bh=iM1TEhHXhHDjnM0SZ1wavSGFzwErB5lnlZV+YnJBxgI=; b=RcqYzuWh8UbiZAgi/zaczLVjS7JndrSymyDWrRQqgRaYIeqxctUzRo1W7gYkk2wpw2 VA/kc5Sc3blLTwSCxxY+X9V5U+qwZuhFq76iRi4wtF+xPWy+guWBXFPenUD7jD+zaRgW ONVyvSSY61HcTJncBC+M0J4ZPHAl58UEW9ys8OlBygXcNmBVjK3tgUXEvD6PVEx0iRCa W5sn7JA6Z8qDOptCtWgXe72Pn3ZktJuQZD2ufPuHv8DQRhiidR+K5rGtscr8fQBQsazz hnZHahd977SSpDenebrSw8wK1QPvZe2xxiCTZZp/LgcOOt285xkuXEWW6FM/psmHqxrR BGMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733984150; x=1734588950; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=iM1TEhHXhHDjnM0SZ1wavSGFzwErB5lnlZV+YnJBxgI=; b=PzxbSXK6jkAQBvSGnOR8Vb8yWAdXrbRp+x6KjLDHX7xVws2Mt6PQs8Mpna1DQnC+Se XVoEs3sYeneU6uL+riJ36liROIeBgbBxAU2/0HXdDjoIAZR2L+JpeFZtlhkpdLywXpQT g357SNhdxxSpy8uz/ytbyWqBNQ3rm5EhaldogfvUhkNu10Ytj2ZgrEhJz5rgecp38AhQ lgB+29eIvbc15TCessenzHjvtRDsZcuADCAnLP4AsqXkcQhuoCH+bMwpsb+T3WQoqo6B mrZ1hPXNqfmcTc8gucfdKQnwHVVoN+MsbfU3AieXwWLG3UsaXZgwtrV3iXvaXV404Bml K0JA== Sender: bitcoindev@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWw8fSYzapD/10Y95EjJSsklk9pWXbXmAL0lQ5cHXJJn75AlejqOGOE6x8jfaKGomploNVd1VjMhSxH@gnusha.org X-Gm-Message-State: AOJu0YwwQIxqeHb9ixK9S+ku+gOKifpQyc48t2qQoxhffCTxzIeSWNMN BK1niJkpVhh/HtPZfQOsM30sU7izMkQLRLce/ePIrDx8T1+eD9o4 X-Google-Smtp-Source: AGHT+IHRlVv6znkrSVOIWTdfZ8qroeZQ65CnnvqcSdNk3wkk7dc9+eWsK/65JyUHhjXj5XGPak4xCg== X-Received: by 2002:ad4:5baa:0:b0:6d8:a5a6:f489 with SMTP id 6a1803df08f44-6dae392ca3bmr32447766d6.26.1733984149646; Wed, 11 Dec 2024 22:15:49 -0800 (PST) X-BeenThere: bitcoindev@googlegroups.com Received: by 2002:a0c:d6c7:0:b0:6d8:ee03:1a2d with SMTP id 6a1803df08f44-6dae3819f18ls673626d6.1.-pod-prod-01-us; Wed, 11 Dec 2024 22:15:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVN2nd33NEce98lVyTp7vkiihW90RWtJpWaED34knRzI1tAabKTaggbb3u7fO4tuRS9LUvTSHRvnr/3@googlegroups.com X-Received: by 2002:ad4:5ae9:0:b0:6d4:3c10:5065 with SMTP id 6a1803df08f44-6dae395ecdfmr31892116d6.32.1733984147551; Wed, 11 Dec 2024 22:15:47 -0800 (PST) Received: by 2002:ae9:f406:0:b0:7b6:d314:a4e5 with SMTP id af79cd13be357-7b6f31a3415ms85a; Wed, 11 Dec 2024 21:50:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVUeuuU1oC972SpP4uVsDML9q6wbJzXycl8PyFpoZ30STQg8xpdvli7YKdeF+ljNPf425DFI/R/eyWy@googlegroups.com X-Received: by 2002:a05:6122:1d51:b0:518:965c:34a with SMTP id 71dfb90a1353d-518b5cc7723mr2364117e0c.2.1733982623301; Wed, 11 Dec 2024 21:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733982623; cv=none; d=google.com; s=arc-20240605; b=iemr6KzjQpmBZ8KmFkpPOOUtZZrpm/x/hevOz4YE/C77k6Hh6QRIzcFYGcPtTTZx8f 05MJpmfeQ4+8CLH5w1ouaqzVf22bvly8ItUTQWyq+yH1oRCQRDF45JZzoT4NRhaqFdhA wGYDmqQTtfYM4mtajPaE5lFkKYEv0S+sGMd/GCPIoEsy4LmJ7eQLKERFL6bmIq2a3R7K GMZpIeY8xZGTQEkWgm0oFmIFV0Iaoyz8RjjNxQcJUBTBgKmRBUdwTF4cYCpimEtQ9cv1 V7/9xDbIp+Ym3Usl4KQHRJOIOU/utgRN3X3eGnbXhVoMPLGMRb1Tzt6CYYzYgyoz+8Ed ebfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:dkim-signature:date; bh=fuFRqH9UFLnkpLejLWc7aWmuKqB/V3HbiXcqtQkX8XA=; fh=roiYaGK86U74SKQPFbJNbEX2eYYfcyTsLRTiAns/QbM=; b=bwGNFCmu5ykod9tKDHqbyYaE2RR0vkP7sZxwBBeMPEA7X02ivsMEFgCZRVIdvazxEM TWxG3u3bvsheqstqPLYOk0vAZlst6woAc2NNXx8ZFcd9EekqcFiKmgfRm7pq8Kcn0I8i 7hXEukamh3HcTuSeqksh3PaRuKgk3tGJk0G+TZmaDAMSynhZ8MQ4tuXjlZTN7iGYuy1n 2GHGsbl80o0/nwKpRZpwseE3u6wyJyxVWf8eVeafiFtbpp+avNiKWOrO0J7k7avKsfYe SKMkzyiQDCUy4PJrOR6h5ImrdsU+hxd15Arwpup8LGj0WgtWnn0s1KDO8U7wfCxmVApt 4qlg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@reardencode.com header.s=mail header.b=JIi738KX; spf=pass (google.com: domain of freedom@reardencode.com designates 2607:f2f8:ad40:ea11::1 as permitted sender) smtp.mailfrom=freedom@reardencode.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=reardencode.com Received: from mail.reardencode.com ([2607:f2f8:ad40:ea11::1]) by gmr-mx.google.com with ESMTPS id 71dfb90a1353d-5161637e295si529166e0c.5.2024.12.11.21.50.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 21:50:22 -0800 (PST) Received-SPF: pass (google.com: domain of freedom@reardencode.com designates 2607:f2f8:ad40:ea11::1 as permitted sender) client-ip=2607:f2f8:ad40:ea11::1; Date: Wed, 11 Dec 2024 21:49:48 -0800 From: Brandon Black To: Rusty Russell Cc: Andrew Poelstra , Weikeng Chen , Bitcoin Development Mailing List Subject: Re: [bitcoindev] Difficulty in emulating "weaker" OP_SUCCESS and why it should be a real opcode Message-ID: References: <87ttbccrql.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline In-Reply-To: <87ttbccrql.fsf@rustcorp.com.au> X-Operating-System: Linux 6.6.36 x86_64 X-Original-Sender: freedom@reardencode.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@reardencode.com header.s=mail header.b=JIi738KX; spf=pass (google.com: domain of freedom@reardencode.com designates 2607:f2f8:ad40:ea11::1 as permitted sender) smtp.mailfrom=freedom@reardencode.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=reardencode.com Precedence: list Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com List-ID: X-Google-Group-Id: 786775582512 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Score: -0.8 (/) On 2024-12-10 (Tue) at 10:51:38 +1030, Rusty Russell wrote: > Brandon Black writes: > > It occurred to me today when thinking about Weikeng's post that we can > > slightly weaken the existing OP_SUCCESS behavior while retaining > > essentially all of its benefits in practice without introducing > > OP_SEGMENT by leveraging OP_CODESEPARATOR. Redefine OP_SUCCESS with a > > soft fork from "make the script unconditionally valid" to "make the > > script segment unconditionally valid", and define a script segment as > > "each lexicographic section of the script containing no > > OP_CODESEPARATOR". > > > > The script interpreter can perform SUCCESS checking as it currently does > > until it encounters an OP_CODESEPARATOR. Each OP_CODESEPARATOR gets a > > "SUCCESS" flag defaulted to false and SUCCESS checking now sets that > > flag to true on the most recently encountered OP_CODESEPARATOR. > > > > During script execution, whenever an OP_CODESEPARATOR is popped (not > > executed) its "SUCCESS" flag value is copied to the interpreter state. > > After this state setting conditional, if the interpreter "SUCCESS" flag > > is true, and fExec is true, the script immediately succeeds. > > Beware success inside branches? This is why I preferred to segment the > script and scan for OP_SUCCESS and evaluate each part in order (if you > have part of an if statement inside one segment, you fail as expected). > This is actually not that different inside Bitcoin's script.cpp. I believe my description of CODESEPARATOR segments has a predictable but different handling of SUCCESS with conditionals. As long as interpreter state change are handled in order: * update success mode if opcode is CODESEPARATOR * if execution enabled by flow control and success mode is true, succeed * execute operation if enabled or operation is flow control That said, I've just reread [BIP342] and realized that the designers of tapscript had greater things in mind for SUCCESS than I had remembered (e.g. the existence of an SUCCESS can be used to change the behavior of other opcodes or even stack limits) which would not work at all well with segmented SUCCESS. Some of these be possible with segmented execution, but not all. Based on this, I'm now in favor of Weikeng's idea for a runtime success operator possibly akin to the original RETURN. If it were equivalent to the original RETURN, it would be a useful alternative to VERIFY in certain cases. > (Also: CODESEPARATOR is cursed, so I chose a different name :) Isn't tapscript CODESEPARATOR uncursed? :) Aside: Because SUCCESS allows for changing resource limits and more, restored script can mostly be implemented in tapscript 0xc0. If any of the new opcodes are present, 1NEGATE is redefined to TX (or something), numbers are bigwholes, limits are varops, etc. Gets a little weird if someone wants to write a restored script without any of the new ops, so maybe you also provide an RESTORE that does nothing other than trigger the mode change. All the best, --Brandon [BIP342]: https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki -- You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group. To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/Z1p5fA6-ZcMtPLOq%40console.