Return-Path: Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id EE160C0032 for ; Mon, 23 Oct 2023 12:26:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B932E61020 for ; Mon, 23 Oct 2023 12:26:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B932E61020 X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: 0.097 X-Spam-Level: X-Spam-Status: No, score=0.097 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, PDS_OTHER_BAD_TLD=1.999, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8uYEzF_LHoPp for ; Mon, 23 Oct 2023 12:26:40 +0000 (UTC) Received: from cerulean.erisian.com.au (azure.erisian.com.au [172.104.61.193]) by smtp3.osuosl.org (Postfix) with ESMTPS id AC21460F9B for ; Mon, 23 Oct 2023 12:26:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org AC21460F9B Received: from aj@azure.erisian.com.au by cerulean.erisian.com.au with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1quu0v-0007Tj-LU; Mon, 23 Oct 2023 22:26:36 +1000 Received: by email (sSMTP sendmail emulation); Mon, 23 Oct 2023 22:26:26 +1000 Date: Mon, 23 Oct 2023 22:26:26 +1000 From: Anthony Towns To: Rusty Russell , Bitcoin Protocol Discussion Message-ID: References: <871qdmulvt.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871qdmulvt.fsf@rustcorp.com.au> X-Spam_score: 0.0 X-Spam_bar: / Subject: Re: [bitcoin-dev] Proposed BIP for OP_CAT X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2023 12:26:42 -0000 On Mon, Oct 23, 2023 at 12:43:10PM +1030, Rusty Russell via bitcoin-dev wrote: > 2. Was there a concrete rationale for maintaining 520 bytes? Without a limit of 520 bytes, then you can construct a script:

CHECKSIGVERIFY {DUP CAT}x10 (we know have a string that is the second witness repeated 1024 times on the stack; if it was 9 bytes, call it 9216B total) {DUP} x 990 (we now have 1000 strings each of length 9216B bytes, for ~9.2MB total) SHA256SUM {CAT SHA256SUM}x999 (we now have a single 32B field on the stack) EQUAL (and can do a hardcoded check to make sure there weren't any shortcuts taken) That raises the max memory to verify a single script from ~520kB (1000 stack elements by 520 bytes each) to ~10MB (1000 stack elements by 10kB each). > 10k is the current script limit, can we get closer to that? :) The 10k limit applies to scriptPubKey, scriptSig and segwit v0 scripts. There's plenty of examples of larger tapscripts, eg: https://mempool.space/tx/0301e0480b374b32851a9462db29dc19fe830a7f7d7a88b81612b9d42099c0ae (3,938,182 bytes of script, non-standard due to being an oversized tx) https://mempool.space/tx/2d4ad78073f1187c689c693bde62094abe6992193795f838e8be0db898800434 (360,543 bytes of script, standard, I believe) Cheers, aj