Delivery-date: Wed, 19 Feb 2025 07:57:45 -0800 Received: from mail-oa1-f62.google.com ([209.85.160.62]) by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tkmSG-0004dC-L6 for bitcoindev@gnusha.org; Wed, 19 Feb 2025 07:57:45 -0800 Received: by mail-oa1-f62.google.com with SMTP id 586e51a60fabf-2bc70bd588bsf874650fac.2 for ; Wed, 19 Feb 2025 07:57:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1739980659; cv=pass; d=google.com; s=arc-20240605; b=Cw2eRPbtpwp49rd6uNAv6CCI79vnwstuw3Z8i0Q0J5vmuTwwJNKlb1rigUwEhxVy+B h4Ev3vcOlpmYySkze/lqG/svBzuQ43/zaRkejjryMRd5tBmhxkByK8q9GmRPrxbzuCqJ MKSVOYsDUOdOvNAc7Iw7xJaIIy/3ceJhOYw/gJ8c4QXlfdILGDD/LsS6tNLT1aisG1FP jfRQu86mh+9YlnYhwWeXc/9eSMJYdQ/gaxcc+lhRF1f7CyKccH3NdMQLyI4apcin6HO6 eYwiRtWcXwq1hDgGpVuiFe5tYlYLYFzTEpd2vUYYrlfWlPDgrDt8ykgZ3apRHKjnRy5R MFNw== 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:to:in-reply-to:cc:references :message-id:date:subject:mime-version:from:content-transfer-encoding :sender:dkim-signature; bh=Q+GNqMewUDkGaEJj0TQLY28i8q8WCE0AUCK4G+2LiEg=; fh=eqPUFdxUuQQ5yavOvPDvYjabBCWUGpY2GkjFIRNltjk=; b=jUMNx9BLK7igy0+mN54WL8YDAYDwyuTfNTm2Wj1ZrgUeluDr2WuC2hVdLGaFnfQyEi 7AOXp7Pv3wUgeJxxPdNftFDUqSxBJ5tIYhxXwNvGI3bPJwdpQQ+Ez7WuE03/1J7p5YTS DU1Pk82jRW9qQh5CXtjD0LnQc823SSfOGop2k0dtNCgNBcvzZ+ZJSyEuLAtM/U7y/5p3 Qd5oxKtb65mgEveCQ3aa4y5V/LppDz5nXWGNijXAg3CnnAD38vc6uzpf+j+76thUvvRp SCuMq+J4EvsFMtD6zTcn3UZ6W8HWyvwE6i+3w2gYQFY4pMceGtODEPm0hS2r8259VFUP 2tcg==; darn=gnusha.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@voskuil-org.20230601.gappssmtp.com header.s=20230601 header.b=vu54BqyV; spf=none (google.com: eric@voskuil.org does not designate permitted sender hosts) smtp.mailfrom=eric@voskuil.org; dara=pass header.i=@googlegroups.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1739980659; x=1740585459; 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:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:sender:from:to :cc:subject:date:message-id:reply-to; bh=Q+GNqMewUDkGaEJj0TQLY28i8q8WCE0AUCK4G+2LiEg=; b=CjiitjfQwpuGX0TuYN+czAbR++2fj8DnsFkEABPMc4S5j5JwnmkpLLWFj+VCXQEbpT wi9A7wT6vWnaGUOrPqAcay+6gHChueAtCvenI1NAgkJcr15nYzAxYYGue9DXLt+n9W6L +MtaLQAqr6AJQkAABpvcNHWCsEpEiK4+57de93NEQQDP9XJ6rn+YqCgiPyRPrCHSwDNo tJDEBl2lkVlo1XDZKpQDbY4CkByCbxAu8b0O2ZpdvP9/Xq48QtiP11BQJD/bff60O647 3tn5ZPikjMIstg7pxKWwYGTmeFy/BZLYe7cVSkkuTQtWXpGONPi67YvyXQk5y7NQszpj nQOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739980659; x=1740585459; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=Q+GNqMewUDkGaEJj0TQLY28i8q8WCE0AUCK4G+2LiEg=; b=sF2a49Vag3wder11UUBwdG181x8bKjAGTWV5+MuVVOAoQ4jJT2fVkzck9DYnO+dsf4 Lzae0LL4z7hBKwcnfv0DelRJ0WPBnrhuAhdJnZcXluNAwnxRDANHm3EijbOEl5x3f6Al 89xSTPl7gR9DWpt8c6WQQCjXBx3MY2NYCcEZTsXm0d9PpA1B+l6ryVIMFrrWTq+K05om BJBPEPM5OTFNR/56lRwaNUYmo8p69VLrVWAGil07YEABbv6LSfh//JiivPcOebXdLcit eYrfGUyvQFPhUnMbruTIydRLyyJ1Ro0e4g8AdyQ36y0wawnGWJL9IYK5MgdYAJzJ285Q BrEg== Sender: bitcoindev@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCU5g7pu3Eng8LmlXh9+52evr8Jqah4u594Zu5X23f9IxUWnr+Ls6Qf1qdwq3qbxIO9gCgt10LRGi/q2@gnusha.org X-Gm-Message-State: AOJu0YwiWluE3IATnjqaRvZTcJHYtW/wZ1BRm9zm8nlgSz7Gxp+9uDrm 5qGwiFcgSWbl7Qe9SAfmgLYvD57k9bovgGGXIgjXE+nYSE1WhOyw X-Google-Smtp-Source: AGHT+IH0etytn+CbhhOkIMyERP2j7hT1T3T0v8TCzoZHf0QC46tyba6+iwIwh3FDabHr1lz/0MfIig== X-Received: by 2002:a05:6870:558d:b0:29e:27b6:be9b with SMTP id 586e51a60fabf-2bc99a78db7mr4123244fac.4.1739980658739; Wed, 19 Feb 2025 07:57:38 -0800 (PST) X-BeenThere: bitcoindev@googlegroups.com; h=Adn5yVHcX6HSEYzkxEs7dJOl458J1nzxaOCngp9ifzR+c/SHjQ== Received: by 2002:a05:6820:1f0d:b0:5fc:f9dc:7a3f with SMTP id 006d021491bc7-5fcf9dc7be4ls612100eaf.1.-pod-prod-02-us; Wed, 19 Feb 2025 07:57:35 -0800 (PST) X-Received: by 2002:a05:6808:4485:b0:3f4:a75:c8a4 with SMTP id 5614622812f47-3f40a75cbf7mr4678914b6e.14.1739980655855; Wed, 19 Feb 2025 07:57:35 -0800 (PST) Received: by 2002:a05:6808:192:b0:3f4:10e6:fe26 with SMTP id 5614622812f47-3f410e70021msb6e; Tue, 18 Feb 2025 21:47:52 -0800 (PST) X-Received: by 2002:a17:902:e841:b0:21f:4144:a06f with SMTP id d9443c01a7336-22103f14b7cmr251135595ad.13.1739944071146; Tue, 18 Feb 2025 21:47:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739944071; cv=none; d=google.com; s=arc-20240605; b=G3rhiairpSqRDuazpTGNZXm5u4ErSvF8SoBuqwW3InFwXQAqU9H52OAVrNxjhS8eXu 0P2Pc/2g69xEL31KzrmYSl6JicimTuYtR5xFzXNZO+9j1keq1pXFmVRArAKyV98ESi7p 9Bv2KvtftK1kc5YPB0DOYEFVH37VHJteBd6iYUJxjntP/FEpRHPvyWIZhUZaDBsnJNiE Ep1nF+h5q5rXsYKQb3cpTc+ovzj/8DAbqBc7RIZfX6IJ3tK+nNIIpj9yM8b1qUZmJTi5 +4b8Rdin9H5jxmIgx2x+5IBk5XKg4D5qzjQeA7rRd+gfKr5sSKcTPzqrDVTW+oUqEGDG Ag4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:dkim-signature; bh=utlk/gEH90Bc/EDlGNjvBD6n/9JzfLsKoxRtO8itKcU=; fh=kXFjjHrPTUpSuZB50K+HVzk4CKSqLNAqA7/YTB/g67c=; b=lGLty0EHBVjQI9IfawQ0oFICtwDWPRHa+SQNB8GVPz7J89x+qfRIhxD+IAC4r5exxn vz1nV4E6Ql8GHuHgdzEsTFxX7Rw+/kkgatWDgxTxFl2Wv+oU+8c2XwcSva7YGZkzrACd EZri+5SXu/Tm4dAQVtXPfDcnkU+MUGq6Gy69DlsfLFpFd4mq8+rl0owQwG8DQY4FCFrC 0V8lUzmY0whvklKlo+ZwP9L/MzC2dOXny/5G8Sl0c4msertCZ3VLyPnuADNvXQmc0Rgd S+j23nVlRdzk6Q448bO0zBHsF0nMDszjoYUS3ASWkWKdNDpq5KEiD6/NTPHMR1/5kocF 6qzA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@voskuil-org.20230601.gappssmtp.com header.s=20230601 header.b=vu54BqyV; spf=none (google.com: eric@voskuil.org does not designate permitted sender hosts) smtp.mailfrom=eric@voskuil.org; dara=pass header.i=@googlegroups.com Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com. [2607:f8b0:4864:20::d34]) by gmr-mx.google.com with ESMTPS id d9443c01a7336-220d47ba258si5534345ad.0.2025.02.18.21.47.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Feb 2025 21:47:50 -0800 (PST) Received-SPF: none (google.com: eric@voskuil.org does not designate permitted sender hosts) client-ip=2607:f8b0:4864:20::d34; Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-855b09fca35so69587139f.3 for ; Tue, 18 Feb 2025 21:47:50 -0800 (PST) X-Gm-Gg: ASbGncvdol0/in+/dWQX7uDf4G1ImvoNf2jJkHInQBx2ndyqaTDmNhNbuw2QMo9+vlg 8CPmC5i90soFTfG8z5ZPobga/0nHHTpssWRMVbSL3RfiIHXMdhNU0YN0pmdRycDLTKmx4Ktow9I MwtXuLhhGoQkRj0U6HrG7waVUWMnR86hqZWGEOv4lQKaco3eS8qmQtEy0sOVxcp0e6dQ6hUpGDs GadErWr8PlOA+83lXkrscKrY13HbIbHINFmHd6joiT14TYaV17lILGsdujWuqmCmEzsSSGR48r2 HwUt4U/NchDFFeKiqLt3sqWAeB8rAzDJkJudDA== X-Received: by 2002:a05:6602:341d:b0:855:bcc9:a8d0 with SMTP id ca18e2360f4ac-855bcc9e16fmr13893339f.11.1739944070093; Tue, 18 Feb 2025 21:47:50 -0800 (PST) Received: from smtpclient.apple ([2600:380:6952:ea2c:39a5:d4be:9057:6373]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-855af4ad010sm40844939f.38.2025.02.18.21.47.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Feb 2025 21:47:49 -0800 (PST) Content-Type: multipart/alternative; boundary=Apple-Mail-EAA761BF-CA27-4CA0-8352-D9AA41D4EA31 Content-Transfer-Encoding: 7bit From: Eric Voskuil Mime-Version: 1.0 (1.0) Subject: Re: [bitcoindev] Transaction Validation Optimization Date: Tue, 18 Feb 2025 23:47:37 -0600 Message-Id: References: <3c2b1e7a-ffcd-41da-a533-2d9224fc016fn@googlegroups.com> Cc: bitcoindev@googlegroups.com, bitcoindev@googlegroups.com In-Reply-To: <3c2b1e7a-ffcd-41da-a533-2d9224fc016fn@googlegroups.com> To: John X-Mailer: iPhone Mail (22B91) X-Original-Sender: eric@voskuil.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@voskuil-org.20230601.gappssmtp.com header.s=20230601 header.b=vu54BqyV; spf=none (google.com: eric@voskuil.org does not designate permitted sender hosts) smtp.mailfrom=eric@voskuil.org; dara=pass header.i=@googlegroups.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: 1.6 (+) --Apple-Mail-EAA761BF-CA27-4CA0-8352-D9AA41D4EA31 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi John,

I don=E2=80=99t = work on BC, so I can=E2=80=99t speak to the specifics of the implementation= , however I=E2=80=99m very familiar with the requirements.

Generally speaking it would be perfectly r= easonable to validate independent txs against their previous outputs and la= ter associate them with a confirming header without revalidating them. This= would hold for segwit and non-segwit txs.

=
However, txs must be validated in the context of a given b= lock. That context cannot be fully known until the associating block header= is known. In Libbitcoin we refer to the required state for validation as = =E2=80=9Ccontext=E2=80=9D. The context for tx validation includes things li= ke height, mtp, timestamp, and active forks.

Height and mtp are known for the next block (ie are a fu= nction of the immediately preceding blocks), but are not applicable to all = subsequent blocks. Timestamp and flags are not known until the associating = header arrives. So the validation performed under certain context assumptio= ns may not hold under an actual context. Finally there must be a mechanism = to control for previous output confirmedness and spentness absent the chang= es that would otherwise occur to a utxo accumulator.
=
Revalidating in the actual block context is one = approach.

e

On Feb 18, 2025, at 21:42, John <= csdarkcounter@gmail.com> wrote:

=EF=BB=BF

Hi everyone,

While analyzing the codebase, I observed wh= at seems to be duplicate validation steps for transactions that already exi= st in the mempool when they appear in new blocks. Specifically, I'm curious= if the secondary validation performed during block acceptance could be saf= ely optimized for SegWit-verified transactions using their wtxid hashes.=EF= =BC=88I'm still working on the source code, and I'm not sure if the source = code was validated twice=EF=BC=89

I'm particularly seeking clarification on two asp= ects: First, does the current implementation indeed perform full re-validat= ion of mempool transactions during block processing? Second, if such optimi= zation is theoretically possible, what subtle risks might emerge regarding = transaction propagation timing or node synchronization that a newcomer like= myself might overlook?

I'd be grateful for any insights about historical design de= cisions in this area, critical code sections I should study more deeply, or= potential pitfalls in this line of thinking. 

Thanks in advance for sharing y= our expertise,
John

--
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 e= mail to bitcoind= ev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitc= oindev/3c2b1e7a-ffcd-41da-a533-2d9224fc016fn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoind= ev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/FDB= FDE56-1D05-493D-8BAC-8E4951780CE1%40voskuil.org.
--Apple-Mail-EAA761BF-CA27-4CA0-8352-D9AA41D4EA31--