Delivery-date: Thu, 04 Jul 2024 06:22:01 -0700 Received: from mail-oa1-f60.google.com ([209.85.160.60]) by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sPMPQ-0001f0-Ks for bitcoindev@gnusha.org; Thu, 04 Jul 2024 06:22:01 -0700 Received: by mail-oa1-f60.google.com with SMTP id 586e51a60fabf-25e1d0ef6d6sf663437fac.3 for ; Thu, 04 Jul 2024 06:22:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720099314; cv=pass; d=google.com; s=arc-20160816; b=JlYyZ06hDex5cGAmNVSxNjOIAJCfl6Nv9Dc0vL61PGOhRmu++RP7f8ADEuJcNUhZyz pvSnjV5Fe+rpfxYQPOJNdfZGUDcPbk3NKk+gWqdzyp8nxCxkbaaTcYE+2HbpKrJt9PfI 4x6C+UuPr14fU74+rvl79Q9/xw9FIrvQnwBTXYEP69W7s1sMw166+ZHBMWYLDrqTdqSd yHzYWJiEXek+mDRQMxNqNUenEWq++GKVnVXkAbkTCC+ajgnDKuDoaHBcY/J1wT3ltHqF S8stLv0MJX+dXgXsRfoydrje7NHAhA4EGHNVhSe0gYRycsJDcGHDEPP4Pzd9Hcd+DyZH VvsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=wss6yclUh0wGxCspujMl3mC6AF/1HD3IWjDHQ6ImcEs=; fh=fzXtaSIoq7PYYZhNjXlppYwCv1+NOESxkQZfl6Al6zw=; b=e0JK1pln7beURTI0rTr6Yf2284VSwCsMDuscttikjUtzrNUja2RofD2h90wF19r2vT BMNGmqBAz+Mt/fDpeRTi0FjoWaWSyVD6UANTxs157FQm5Eo3Z21RCCtZxYONPlAfvYbv u5HWlYzdZHHGz6ofZX+M2BnFvq3JWh/ZmWf+vWY3JVl5W32udYXPwEBqI0XiOjoWAo8U P64pCIdWC9tZVlby7s38+svVr/DwzKsW67FpIl2lYypjWaeBkYMHFrozxfNIyJCbwt9t Osh/FMVNdmE3q1RDztGNjHreVjw0Xulm66/fRxDVTVdsMll5RxMg3dHHnvUq2nVhPKHh H9kg==; darn=gnusha.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y9h0Q4UX; spf=pass (google.com: domain of antoine.riard@gmail.com designates 2607:f8b0:4864:20::d35 as permitted sender) smtp.mailfrom=antoine.riard@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1720099314; x=1720704114; 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:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:sender:from:to:cc:subject:date:message-id :reply-to; bh=wss6yclUh0wGxCspujMl3mC6AF/1HD3IWjDHQ6ImcEs=; b=YbxHv80jpC5pEckL782aLmec1gHIBFiAlAE5Xr/sa6O7uXr9hZLyaRtEzGqu8LIv0G ICqlkP3CV34bLPf4EcoG+mOZNSVxz91jYvu3SgKUOD4MSDZkqTXa8h5d7XBdZEvs1fLa L8gjSbAjGi3qhZhhn4cCvGp6wYL3LmptRF2+MtS5z4EtDZvZyxvoo+/P2rW9Y/E5i3cL pV06zzvnwWduYEvCMq/kzTmez66iKL8gNjHEhzA1kHVTTiLidZm3+yCo4IG3886wub8/ VbuJrDUcFCydFNo1CoMUeShQ6Y6b63L+blGv0jt19gPhDGgMnt5Xj4Lk8+cgOCoV05Qe eIGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720099314; x=1720704114; 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:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wss6yclUh0wGxCspujMl3mC6AF/1HD3IWjDHQ6ImcEs=; b=kmmm5Y43NSpcZMUfqB1azxzFuTX4yC6AR09m4Uz30WNB8YJY/KAtKE8ocWLfVj+npG +d+6QkOJ1QgbU8YJh67jhLQuS7WEmDbi7stG+vUMvAAm8b9vtckfPDeMDqMB7tpGyJ6H ZzzcQMSwhov9Cpg5KIBOmaDTkeszeFkn8s36D0MJdEo5Vzb84IXEYpaOgEARoC1Dvg2b zVahP1KfHdc7eJI3sGP34Rqfv4/WTf1tE/UooW76oiM8N0KgqMN+W0pjD5hty57jHpbl FmSCz/2Di/p+nizGW1wAB/qnLnoyeo/m4lxS0PpYZsjmWyN7h96rhb+oKhkDajnRuiZm u7WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720099314; x=1720704114; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=wss6yclUh0wGxCspujMl3mC6AF/1HD3IWjDHQ6ImcEs=; b=XrmqUY7KFoKnoeFX4kK68bDgec/073dDVmZbH51OxNoAamdy3Du4Bp0GN0dBBvMMxc sK7XdaCdQHzqRbbC1OwtH2SrxZuk4X6Ix35L8tW93lhVdX5y+70kLoS3s/ePuRFERxsD 5GeVFjQgYfCsWJLq5ZAy6arCsaAxqHKxIf6yRt2/xy3VCZC3oHvc3B+BC3qFx2F8+sX0 DIu5JNefH45eIt3GmW3hKI9WAzpyMIxL3DjWnc/GDuVY+QgYpUr+pHyOSCVtLeFLTqIh Tr3c1MaimHzthzIZvvzzyF9xR358EmgdLkL7WHqfb5cFVPNiC/EXmmNI9UeNLDK3s6Tu hCuQ== Sender: bitcoindev@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCX8DKJtdvv5t6/izXfNeAPSi3WIDA1HQgFGsaODWJITqZOa1YUiJwl9FJ0Em/ewzI81Y3G1veH844md8r04c+KDETKiZ+o= X-Gm-Message-State: AOJu0YwElt4H/T7fTMf4C6saB0Na7SAoxcnDWHIzYN9cu2rrJh5TwlVH pBkj3k8SOPsH4Uuv7Q8XChiwlYy9wY5Wr9dc4HESy0CX0l6lzznV X-Google-Smtp-Source: AGHT+IGGAH+C1QDlFc0putC9jl9/VKRac/com6JqIup79JgxJ+Y261qd/MvPfyKJzbYuQdfYW5mcOg== X-Received: by 2002:a05:6871:24cd:b0:24f:cddc:ccfe with SMTP id 586e51a60fabf-25e2b59025fmr1415152fac.0.1720099314208; Thu, 04 Jul 2024 06:21:54 -0700 (PDT) X-BeenThere: bitcoindev@googlegroups.com Received: by 2002:a05:6871:708:b0:259:8c55:f25a with SMTP id 586e51a60fabf-25e27dd6d81ls885881fac.0.-pod-prod-05-us; Thu, 04 Jul 2024 06:21:52 -0700 (PDT) X-Received: by 2002:a05:6871:10a:b0:254:cbaf:120b with SMTP id 586e51a60fabf-25e2b9de84cmr113048fac.1.1720099312717; Thu, 04 Jul 2024 06:21:52 -0700 (PDT) Received: by 2002:aca:1c0c:0:b0:3d5:202d:f617 with SMTP id 5614622812f47-3d852bea3c1msb6e; Thu, 4 Jul 2024 06:21:10 -0700 (PDT) X-Received: by 2002:a17:902:f645:b0:1f9:b681:194b with SMTP id d9443c01a7336-1fb33e4133bmr14379485ad.22.1720099269754; Thu, 04 Jul 2024 06:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720099269; cv=none; d=google.com; s=arc-20160816; b=Pu95wkOm13dXIapXaueP0hdfvw1p5c7z94n3456q+HPkNLDThgzK7nOlWgHhf/IZ9a D5O61tDmCCJxpN1xzPPscoVKdJGZCG/VfvXJ6TpOFIYQ9HWn6H7dn19h7ezDMV8spnAv yTjrytIPud6Vw7E1tsXs1MWiics7Zr9ySsR5WSGcsPyk16KHM5OVksRJCfb9lGXlIKA2 8NqwAjtjwQMvEeCwngnCUZOYFPxUj1DEyRAQciopSl40dnIFKWPEJmGZ2v12YxaqFplh oRk4ROD1NSfwWVxyVIRqWGDtCDC1Po5IndpsZ7ihwtpgNSi6s2eUVUsl8YoYDO6f49hk J27A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Fl61C9c0fJzbBnKHiU6CfLfG9E7vpzOfvbwz/1swJrM=; fh=VUyRMGDsLDyKXHBc8DWjokFBiSMTvXavinKdBJZhUls=; b=jBZle0RaqbOHIXLVF2Gwia8mHeWE/P+XtLl4Li0z3dognXGsWj7J42KDpKfYyHUfCe YdbhsZpJkK+w3/mP28wQgW77MDTnnBOD3b5Tdnfm2z4gMF5bpZCVPX9OJfFNdcPiUd7Z tK4+g9OfMCeSzJLi3XiGXd6NtRTwvy3utTXuJcXTrKYOVa4UZsLgVKNhoEbcUYBNpXGQ 7oN0ZyfGpgSfgs/+htbUGFZivmBowa2InaZG8MsszlZZGCqjTnYZvP+240FSuxojn2UU AjAVzUmvSPJIQLsMcWUHdk7hzYBth5E82DsSql1prshBy9FeWzn7p7idFVxrrsBu/Sht sbrQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y9h0Q4UX; spf=pass (google.com: domain of antoine.riard@gmail.com designates 2607:f8b0:4864:20::d35 as permitted sender) smtp.mailfrom=antoine.riard@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com. [2607:f8b0:4864:20::d35]) by gmr-mx.google.com with ESMTPS id d9443c01a7336-1fafc0f2d5csi1731905ad.9.2024.07.04.06.21.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Jul 2024 06:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of antoine.riard@gmail.com designates 2607:f8b0:4864:20::d35 as permitted sender) client-ip=2607:f8b0:4864:20::d35; Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7eb895539e3so26214039f.2 for ; Thu, 04 Jul 2024 06:21:09 -0700 (PDT) X-Received: by 2002:a05:6602:15:b0:7f6:6634:f382 with SMTP id ca18e2360f4ac-7f66dec2392mr195189539f.9.1720099268894; Thu, 04 Jul 2024 06:21:08 -0700 (PDT) MIME-Version: 1.0 References: <72e83c31-408f-4c13-bff5-bf0789302e23n@googlegroups.com> <5b0331a5-4e94-465d-a51d-02166e2c1937n@googlegroups.com> <9a4c4151-36ed-425a-a535-aa2837919a04n@googlegroups.com> <3f0064f9-54bd-46a7-9d9a-c54b99aca7b2n@googlegroups.com> <26b7321b-cc64-44b9-bc95-a4d8feb701e5n@googlegroups.com> <607a2233-ac12-4a80-ae4a-08341b3549b3n@googlegroups.com> <3dceca4d-03a8-44f3-be64-396702247fadn@googlegroups.com> <301c64c7-0f0f-476a-90c4-913659477276n@googlegroups.com> <33dfd007-ac28-44a5-acee-cec4b381e854n@googlegroups.com> In-Reply-To: <33dfd007-ac28-44a5-acee-cec4b381e854n@googlegroups.com> From: Antoine Riard Date: Thu, 4 Jul 2024 14:20:57 +0100 Message-ID: Subject: Re: [bitcoindev] Re: Great Consensus Cleanup Revival To: Eric Voskuil Cc: Bitcoin Development Mailing List Content-Type: multipart/alternative; boundary="000000000000e6ad67061c6bd10c" X-Original-Sender: antoine.riard@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y9h0Q4UX; spf=pass (google.com: domain of antoine.riard@gmail.com designates 2607:f8b0:4864:20::d35 as permitted sender) smtp.mailfrom=antoine.riard@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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.5 (/) --000000000000e6ad67061c6bd10c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > I assume this function lets you search for an element starting in the middle of a single-linked list (the middle because you could call `ft_list_find(&p-next, data_ref)` where `p` points to any element in the > middle of the list, including possibly the last item in the list, in which case the loop body wouldn't run). If so, I don't think this does what's intended. This actually unlinks (and memory-leaks) elements up to > where the match is found. I think you want to advance `start_list` this way (I didn't test this): Note the usage of a pointer to pointer so the correct way to call the code is : `pointer_t * list_ptr ; list_ptr =3D first_list_element ; ft_list_find(list_ptr, data_rf, cmp);`. This is correct that if you point to the last item in the list, the loop body wouldn't run (which is the expected behavior). When there is a match, the pointer `*start_list` takes as value the memory address of the next element in the list, the contained structure pointer is not changed. The code has been tested a while back, though it's indeed clearer if a typedef `pointer_t` for list is fully given: ``` typedef struct s_list { void *content; size_t content_size; struct s_list. *next; } pointer_t ``` > This is why we don't use C - unsafe, unclear, unnecessary. Actually, I think libbitcoin is using its own maintained fork of secp256k1, which is written in C. For sure, I wouldn't recommend using C across a whole codebase as it's not memory-safe (euphemism) though it's still un-match if you wish to understand low-level memory management in hot paths. It can be easier to use C++ or Rust, though it doesn't mean it will be as (a) perf optimal and (b) hardened against side-channels. I have not read in detail the last Eric's email on the whole caching identity in case of invalidity discussion, though I'll do so. Best, Antoine Le jeu. 4 juil. 2024 =C3=A0 00:57, Eric Voskuil a =C3=A9= crit : > This is why we don't use C - unsafe, unclear, unnecessary. > > e > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Bitcoin Development Mailing List" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/bitcoindev/CAfm7D5ppjo/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > bitcoindev+unsubscribe@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/bitcoindev/33dfd007-ac28-44a5-acee-cec4= b381e854n%40googlegroups.com > > . > --=20 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 bitcoindev+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/= bitcoindev/CALZpt%2BFs1U5f3S6_tR7AFfEMEkgBPSp3OaNEq%2BeqYoCSSYXD7g%40mail.g= mail.com. --000000000000e6ad67061c6bd10c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> I assume this function lets you search for an element= starting in the middle of a single-linked list (the middle because you cou= ld call `ft_list_find(&p-next, data_ref)` where `p` points to any eleme= nt in the
> middle of the list, including possibly the last item in = the list, in which case the loop body wouldn't run). If so, I don't= think this does what's intended. This actually unlinks (and memory-lea= ks) elements up to > where the match is found. I think you want to advan= ce `start_list` this way (I didn't test this):

Note = the usage of a pointer to pointer so the correct way to call the code is : = `pointer_t * list_ptr ; list_ptr =3D first_list_element ; ft_list_find(list= _ptr, data_rf, cmp);`.
This is correct that if you point to the l= ast item in the list, the loop body wouldn't run (which is the expected= behavior). When there is a match, the pointer `*start_list` takes as value= the memory address of the next element in the list, the contained structur= e pointer is not changed. The code has been tested a while back, though it&= #39;s indeed clearer if a typedef `pointer_t` for list is fully given:=C2= =A0

```
typedef struct =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s_list
{
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0void =C2=A0 =C2=A0 *content;
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0si= ze_t =C2=A0content_size;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct =C2=A0s_list. *n= ext;
} =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pointer_t
```

> This is why we don= 't use C - unsafe, unclear, unnecessary.

A= ctually, I think libbitcoin is using its own maintained fork of secp256k1, = which is written in C.
For sure, I wouldn't recommend using C= across a whole codebase as it's not memory-safe (euphemism) though it&= #39;s still un-match if you wish to understand low-level memory management = in hot paths.
It can be easier to use C++ or Rust, though it does= n't mean it will be as (a) perf optimal and (b) hardened against side-c= hannels.

I have not read in detail the last Eric&#= 39;s email on the whole caching identity in case of invalidity discussion, = though I'll do so.

Best,
Antoine


Le=C2=A0jeu. 4 juil. 2024 =C3=A0=C2=A000:57, Eric Voskuil = <eric@voskuil.org> a =C3=A9cr= it=C2=A0:
This is why we don't use C - unsafe= , unclear, unnecessary.

e

--
You received this message because you are subscribed to a topic in the Goog= le Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this topic, visit https://group= s.google.com/d/topic/bitcoindev/CAfm7D5ppjo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bitco= indev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://g= roups.google.com/d/msgid/bitcoindev/33dfd007-ac28-44a5-acee-cec4b381e854n%4= 0googlegroups.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 on the web visit https://groups.= google.com/d/msgid/bitcoindev/CALZpt%2BFs1U5f3S6_tR7AFfEMEkgBPSp3OaNEq%2Beq= YoCSSYXD7g%40mail.gmail.com.
--000000000000e6ad67061c6bd10c--